# @Time    :2025/3/27 10:04

"""
实现一个动态数组

"""
class Array:
    def __init__(self):
        """初始化数组"""
        self.__capacity = 8
        self.__size = 0
        self.__items = [0] * 8

    def __str__(self):
        """打印数组"""
        arr_str = "["
        for i in range(self.__size):
            arr_str += str(self.__items[i])
            if i < self.__size - 1:
                arr_str += ", "
        arr_str += "]"
        return arr_str

    @property
    def size(self):
        """获取数组元素个数"""
        return self.__size

    def is_empty(self):
        """判断数组是否为空"""
        return self.__size == 0
"""
数组扩容

"""

def __grow(self):
    """数组扩容"""
    self.new___items = [0] * self.__capacity * 2
    for i in range(self.__size):
        self.new___items[i] = self.__items[i]
    self.__items = self.new___items
    self.__capacity *= 2
